package com.service.impl;


import com.common.mybaits.CustomPage;
import com.domain.DO.User;
import com.domain.DTO.UserDto;
import com.domain.VO.UserVO;
import com.mapper.UserMapper;
import com.service.IUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

import static com.domain.factory.UserFactory.USER_CONVERT;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 大忽悠
 * @since 2022年11月08日
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {

    @Override
    public void save(UserVO userVO) {
        User user = USER_CONVERT.toUser(userVO);
        save(user);
    }

    @Override
    public List<UserDto> list(CustomPage customPage) {
        List<User> userList = CustomPage.getResult(customPage, new User(), this, null);
        return USER_CONVERT.toListUserDto(userList);
    }
}
